{extend name='public/layout' /}
{block name='content'}
<div>
    <div class="position"><p>您的当前位置：<a href="{:url('Index/index')}">首页</a>  >  <a href="{:url('Question/index')}">问答</a>
    </p>
    </div>
    <div class="div_box">
        <div class="ask_show01_n1">
            <h1>{$info.title}</h1>
            <p><span class="more">{$info.create_time|date='Y-m-d H:i:s',###}</span>提问者：{$info.user_name} 浏览 {$info.hits} 次</p>
            <div>{$info.content}</div>
        </div>
        <div class="ask_show01_n2">
            <input type="hidden" id="ask_id" value="{$info.id}">
            <p><textarea class="inp09" name="textarea" id="answer_content" placeholder="请输入您的回答..." style="width: 99%" rows="5"></textarea></p>
            <p><a id="answerBut" href="javascript:;" data-uri="{:url('Ajax/answer')}" class="but03">提交回答</a></p>
        </div>
    </div>

    <div class="div_box">
        <h1 class="h1_title"><span class="h1_title_t">网友回答</span></h1>
        {volist name="moreAnswer" id='vo'}
        <div class="ask_show03 overflow_h">
            <span class="ask_main_img"><a href="javascript:;"><img src="{$vo.user.headimgurl}"></a></span>
            <dl>
                <dt><span class="ask_show03_t_s1">{$vo.create_time|date='Y-m-d H:i',###}</span>回答者：<span class="org04"><a href="javascript:;">{$vo.user.nickname}</a></span> </dt>
                <dd>{$vo.content}</dd>
                <dd><p data-bid="{$vo.id}" data-uri="{:url('Ajax/fabulous')}"><span data-boxtype="top" data-type="good" class="ask_show03_t_s2">{$vo.good}</span><span data-boxtype="step" data-type="bad" class="ask_show03_t_s3">{$vo.bad}</span></p></dd>
            </dl>
        </div>
        {/volist}
        <div class="plastic_bottom_pages">
            {$pages}
        </div>
    </div>

    <div class="div_box">
        <h1 class="h1_title"><span class="h1_title_t">相关问答</span><span class="more"><a href="{:url('Question/index',['cate_id'=>$info['cate_id']])}">更多 ></a></span></h1>
        <div class="houses_inf">
            <ul>
                {php}$cate_id=$info['cate_id'];$cityid=$cityInfo['id'];{/php}
                {fang:lists table='ask' field='id,title' where="status=1 and city=$cityid and cate_id=$cate_id" order='id desc' limit='5' id='vo'}
                <li><a title="{$vo.title}" href="{:url('Question/detail',['id'=>$vo['id']])}">{$vo.title}</a></li>
                {/fang:lists}
            </ul>
        </div>
    </div>
</div>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/plugins/jquery.ajax.form.js"></script>
<script>
    $(function(){
        $('.ask_show03_t_s2,.ask_show03_t_s3').bind('click',function(){
            var type = $(this).data('type'),me=$(this),id=$(this).parent().data('bid'),url=$(this).parent().data('uri');
            var param = {id:id,type:type};
            $.post(url,param,function(res){
                if(res.status == 1){
                    layer.msg(res.msg,{icon:1});
                    me.text(parseInt(me.text())+1);
                }else{
                    layer.msg(res.msg,{icon:2});
                }
            });
        });
        $('#answerBut').bind('click',function(){
            var ask_id = $('#ask_id').val(),content=$('#answer_content').val(),url=$(this).data('uri');
            if($.trim(content).length==0){
                layer.msg('请填写答案后再提交');
            }else{
                var param = {ask_id:ask_id,content:content};
                $.post(url,param, function (res) {
                    if(res.status == 1){
                        layer.msg(res.msg,{icon:1});
                        setTimeout(function(){window.location.href=location.href+'?t='+Math.random();},2000);
                    }else{
                        layer.msg(res.msg,{icon:2});
                    }
                })
            }
        });

    });
</script>
{/block}
